

    <link href="/jison/assets/styles/try.css" type="text/css" rel="stylesheet" media="screen" />

  <div id="try">
    <h1>Try Jison Online</h1>
    <p>Build, test, and download your parser from the web!</p>
    <h2>Describe Your Language</h2>

    <p>
    Load an example:
    <select id="examples">
      <option value="calculator.jison" selected="true">Calculator</option>
      <option value="lambdacalc.jison">Lambda Calculus</option>
      <!--<option value="ansic.jison">ANSI C</option>-->
    </select>
    </p>

    <textarea id="grammar" rows="20" cols="80">
/* description: Parses end executes mathematical expressions. */

/* lexical grammar */
%lex
%%

\s+                   /* skip whitespace */
[0-9]+("."[0-9]+)?\b  return 'NUMBER'
"*"                   return '*'
"/"                   return '/'
"-"                   return '-'
"+"                   return '+'
"^"                   return '^'
"("                   return '('
")"                   return ')'
"PI"                  return 'PI'
"E"                   return 'E'
<<EOF>>               return 'EOF'
.                     return 'INVALID'

/lex

/* operator associations and precedence */

%left '+' '-'
%left '*' '/'
%left '^'
%left UMINUS

%start expressions

%% /* language grammar */

expressions
    : e EOF
        {return $1;}
    ;

e
    : e '+' e
        {$$ = $1+$3;}
    | e '-' e
        {$$ = $1-$3;}
    | e '*' e
        {$$ = $1*$3;}
    | e '/' e
        {$$ = $1/$3;}
    | e '^' e
        {$$ = Math.pow($1, $3);}
    | '-' e %prec UMINUS
        {$$ = -$2;}
    | '(' e ')'
        {$$ = $2;}
    | NUMBER
        {$$ = Number(yytext);}
    | E
        {$$ = Math.E;}
    | PI
        {$$ = Math.PI;}
    ;
</textarea>
    <p>
      <button id="process_btn">Generate Parser</button>
      <button id="download_btn" disabled>Download</button>
    </p>
    <pre id="gen_out"></pre>

    <div id="nonterminals"></div>
    <div id="productions"></div>
    <div id="table"></div>


    <div id="parsing">
      <h2>Test Your Parser</h2>
      <textarea id="source" rows="8" cols="80">5*PI^2</textarea><br/>
      <button id="parse_btn">Parse</button>
    </div>
    <pre id="out"></pre>

    <div id="loading"></div>
  </div>

  <div id="usf">
    <h2>Suggestion</h2>
    <p>You may also want to try <a href="usf/index.html">the Jison USF page</a> which includes logic to show the productions and state transition diagram. This can be very useful for debugging your grammar!</p>
  </div>

    <script src="/jison/assets/js/webtoolkit.js"></script>
    <script src="/jison/assets/js/jquery.js"></script>
    <script src="/jison/assets/js/json2.js"></script>
    <script src="/jison/assets/js/es5.js"></script>
    <script src="/jison/assets/js/jison.js"></script>
    <script src="/jison/assets/js/try.js"></script>
